package com.superman.dao.impl;

import com.superman.dao.ICategoryDao;
import com.superman.entity.Brand;
import com.superman.entity.Category;
import com.superman.util.JDBCTemplate;
import com.superman.util.ResultSetHandler;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

public class CategoryDaoImpl implements ICategoryDao {

    @Override
    public List<Category> queryCategory() throws SQLException, ClassNotFoundException {
        String sql = "SELECT * FROM t_category";
        return JDBCTemplate.query(sql, null, new ResultSetHandler<Category>() {
            @Override
            public Category handleRow(ResultSet rs) throws SQLException {
                return new Category(rs.getString("id"), rs.getString("name"));
            }
        });
    }
}
